# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day105_pyqt5_center
   Description :
   Author :       fuml
   date：          2019/9/20
-------------------------------------------------
   Change Activity:
                   2019/9/20:
-------------------------------------------------
"""
import  sys
from PyQt5.QtWidgets import (QApplication,QWidget,QDesktopWidget)
from PyQt5.QtCore import QRect

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.resize(250,150)
        self.center()

        self.setWindowTitle('move window to screen center')
        self.show()
    def center(self):
        #获得窗口尺寸
        qr = self.frameGeometry()
        print(type(qr))
        # 获得中心点坐标
        cp =QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())